function [f, g, h] = L_sigma_02 (x, model)


x=x';

N     = model.N;
k     = model.k;
k_hat = model.k_hat;

term01 = -sum(model.sigma_2.^2,1);
term02 = -sum(((repmat(model.alpha_02,N,1)-model.alpha_2).^2),1);
term03 = -((model.eta.^2)*(sum((model.sigma_1.^2+model.alpha_1.^2),1))')';

term04 = 0;

  for m=1:k
     for l=1:(m-1)
        term04 = term04 - (model.eta(:,l).*model.eta(:,m))*sum(model.alpha_1(:,l).*model.alpha_1(:,m));
     end
  end
  
term04 = term04';
term05 = 2*sum((model.eta*model.alpha_1')'.*(model.alpha_2-repmat(model.alpha_02,N,1)),1);
  
term06 = term01 + term02 + term03 + term04 + term05;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

term1  = (-N/2)*(sum(log(2*pi*x.^2)));
term2  = sum(term06./(2*x.^2));

f      = -(term1+term2);


%% specifying the Jacobian


term11 = -N./x;
term12 = term06./(x.^3);

g      = -(term11+term12)';

%% specifying the Hessian

term21 = N./(x.^2);
term22 = -(3*term06)./(x.^4);

h      = -diag(term21+term22);

end
